//
//  GoodDetailFirstVC.m
//  NormalFramework
//
//  Created by beisheng03 on 2018/3/10.
//  Copyright © 2018年 beisheng. All rights reserved.
//GoodDetailSecendVC

#import "GoodDetailFirstVC.h"
#import "GoodDetailImagesCell.h"
#import "GoodsDetHeaderTwo.h"
#import "GoodsDetHeaderOne.h"
#import "GoodsDetHeaderThree.h"
#import "GoodsDetArrorCell.h"
#import "GoodsDetaCollctionCell.h"
#import "DetaliTrendLineCell.h"
#import "GoodsDetalListCell.h"
#import "TaDePersonalCenter.h"
#import "GoodsDetSecendCell.h"
#import "GoodsDetailBianCell.h"

#import "GoodsDetZanWeiCell.h"
@interface GoodDetailFirstVC ()
/** <#note#> */
@property (nonatomic, strong) NSMutableArray<NSObject *> *dataModel;
@end

@implementation GoodDetailFirstVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    self.tableView.showsVerticalScrollIndicator = NO;
    
    self.tableView.backgroundColor = [UIColor whiteColor];
    
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    if (@available(iOS 11.0, *)) {
        
       
        self.tableView.estimatedSectionFooterHeight = 0;
        self.tableView.estimatedSectionHeaderHeight = 0;
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        
    }
    
     self.tableView.estimatedRowHeight = 200;
    self.tableView.rowHeight = UITableViewAutomaticDimension;

    self.tableView.contentInset = UIEdgeInsetsMake(IPhoneX ? 88 : 64, 0, IPhoneX ? 83 : 49, 0);
    
    
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([GoodDetailImagesCell class]) bundle:nil] forCellReuseIdentifier:[GoodDetailImagesCell identifierStr]];
    
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([GoodsDetArrorCell class]) bundle:nil] forCellReuseIdentifier:[GoodsDetArrorCell identifierStr]];
    
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([GoodsDetaCollctionCell class]) bundle:nil] forCellReuseIdentifier:[GoodsDetaCollctionCell identifierStr]];

    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([GoodsDetalListCell class]) bundle:nil] forCellReuseIdentifier:[GoodsDetalListCell identifierStr]];
    
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([GoodsDetSecendCell class]) bundle:nil] forCellReuseIdentifier:[GoodsDetSecendCell identifierStr]];

    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([GoodsDetailBianCell class]) bundle:nil] forCellReuseIdentifier:[GoodsDetailBianCell identifierStr]];
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([GoodsDetZanWeiCell class]) bundle:nil] forCellReuseIdentifier:[GoodsDetZanWeiCell identifierStr]];


    
    
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([DetaliTrendLineCell class]) bundle:nil] forCellReuseIdentifier:[DetaliTrendLineCell identifierStr]];


    
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([GoodsDetHeaderOne class]) bundle:nil] forHeaderFooterViewReuseIdentifier:[GoodsDetHeaderOne identifierStr]];
    
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([GoodsDetHeaderTwo class]) bundle:nil] forHeaderFooterViewReuseIdentifier:[GoodsDetHeaderTwo identifierStr]];

    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([GoodsDetHeaderThree class]) bundle:nil] forHeaderFooterViewReuseIdentifier:[GoodsDetHeaderThree identifierStr]];

    
    
    // Do any additional setup after loading the view.
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 5;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
   
    if (section == 0) {
        return 3;
    } else if (section == 1){
        
        return 1;
    } else if (section == 2){
        return 1;
    }else if (section == 3){
        return 3;
    }else{
        
        return 50;
        
    }

    
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    if (indexPath.section == 0) {
        
        if (indexPath.row == 0) {
            
            GoodDetailImagesCell *cell = [tableView dequeueReusableCellWithIdentifier:[GoodDetailImagesCell identifierStr]];
            
            return  cell;
            
        } else if (indexPath.row == 1){
            
            GoodsDetSecendCell *cell = [tableView dequeueReusableCellWithIdentifier:[GoodsDetSecendCell identifierStr]];
            
            cell.goodsName = @"Apple iPhone X (A1865) 64GB 深空灰色 移动联通电信4G手机";
            
            return  cell;
            
        }else{
            
            GoodsDetailBianCell *cell = [tableView dequeueReusableCellWithIdentifier:[GoodsDetailBianCell identifierStr]];
            
            return  cell;
            
        }
        
    } else if (indexPath.section == 1){
        DetaliTrendLineCell *cell = [tableView dequeueReusableCellWithIdentifier:[DetaliTrendLineCell identifierStr]];
        
        return  cell;
        
    } else if (indexPath.section == 2){
        
 
            GoodsDetaCollctionCell *cell = [tableView dequeueReusableCellWithIdentifier:[GoodsDetaCollctionCell identifierStr]];
            
            return  cell;
       
    } else if (indexPath.section == 3){
        
        if (indexPath.row == 0) {
            GoodsDetArrorCell *cell = [tableView dequeueReusableCellWithIdentifier:[GoodsDetArrorCell identifierStr]];
            
            cell.index = indexPath;
            
            return  cell;
        } else if (indexPath.row == 1) {
            
            GoodsDetArrorCell *cell = [tableView dequeueReusableCellWithIdentifier:[GoodsDetArrorCell identifierStr]];
             cell.index = indexPath;
            return  cell;
            
        }else{
            
            GoodsDetZanWeiCell *cell = [tableView dequeueReusableCellWithIdentifier:[GoodsDetZanWeiCell identifierStr]];
            
//            cell.contentView.backgroundColor = viewBgGrey;
            
            return  cell;
            
        }
    }else{
        
        GoodsDetalListCell *cell = [tableView dequeueReusableCellWithIdentifier:[GoodsDetalListCell identifierStr]];
        
        return  cell;
    }
    
   
    
}






- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    

    if (indexPath.section == 4) {
        
        TaDePersonalCenter *temp = [[TaDePersonalCenter alloc]init];
        
        
        [self.navigationController pushViewController:temp animated:YES];
        
    }
    
}






- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    if (section == 0) {
        return 0;
    } else if (section == 1){
        
        return 44;
    } else if (section == 2){
        return 44;
    } else if (section == 3){
        return 0;
    }else{
        
        return 44;
        
    }
    
}




- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    
    return 0;

   
}




- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    if (section == 0) {
        return [[UIView alloc]init];
    } else if (section == 1){
        
        GoodsDetHeaderOne *temp = (GoodsDetHeaderOne *)[tableView dequeueReusableHeaderFooterViewWithIdentifier:[GoodsDetHeaderOne identifierStr]];
        
        return temp;
    } else if (section == 2){
        
        GoodsDetHeaderTwo *temp = (GoodsDetHeaderTwo *)[tableView dequeueReusableHeaderFooterViewWithIdentifier:[GoodsDetHeaderTwo identifierStr]];
        
        
        return temp;
        
    }else if (section == 3){
        
        return [[UIView alloc]init];
        
    }else{
        
        GoodsDetHeaderThree *temp = (GoodsDetHeaderThree *)[tableView dequeueReusableHeaderFooterViewWithIdentifier:[GoodsDetHeaderThree identifierStr]];
        
        
        return temp;
        
    }
    
    
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    
    return [[UIView alloc]init];


    

}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
